﻿using System;
using System.Collections.Generic;
using NRFramework;
using QFramework;

namespace Gp.Scripts.Core
{
    public class GUIWidget : UIWidget
    {
        protected readonly EventHandler EventHandler = new();
        

        /// <summary>
        /// 子类析构唯一接口 
        /// </summary>
        protected virtual void OnExit() { }
        /// <summary>
        /// 子类初始化唯一接口
        /// </summary>
        protected virtual void OnEnter() { }

        protected sealed override void AfterCreated() { base.AfterCreated(); }
        protected sealed override void OnCreating() { base.OnCreating(); }
        protected override void OnInternalCreated()
        {
            base.OnInternalCreated();
            OnEnter();
        }


        protected sealed override void InternalExit()
        {
            // 自动注销所有注册过的事件
            EventHandler.UnRegisterAll();
            OnExit();
        }
        

        protected sealed override void OnInternalRemoved()
        {
            base.OnInternalRemoved();
        }

        protected sealed override void OnInternalRemoving()
        {
            base.OnInternalRemoving();
        }
    }
}